import com.guo.App;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@SpringBootTest(classes = App.class)
@RunWith(SpringRunner.class)
public class JedisTest1 {
    /*
    * @Autowired
    * @Qualifier(name = "redisTemplate")
    * */

    @Resource(name = "redisTemplate")  //1.跟类型匹配 2.默认用变量名查找对象 3.根据指定名字查找对象
    private RedisTemplate rt;

    @Test
    public void test(){
        rt.opsForValue().set("token","15514212124",20, TimeUnit.SECONDS);
    }

    @Test
    public void test1(){
        System.out.println(rt.opsForValue().get("token"));
    }
}
